import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import { createRequire } from 'node:module';
const require = createRequire( import.meta.url );
//引入node提供内置模块path：可以获得绝对路径
import ckeditor5 from '@ckeditor/vite-plugin-ckeditor5'
import {fileURLToPath} from "node:url";
import VueSetupExtend from 'vite-plugin-vue-setup-extend'
export default defineConfig( {
    plugins: [
        vue(),
        VueSetupExtend(),
        ckeditor5( { theme: require.resolve( '@ckeditor/ckeditor5-theme-lark' ) } )
    ],
    resolve: {
        alias: {
            '@': fileURLToPath( new URL( './src', import.meta.url ) )
        }

    },
    server: {
        host: '127.0.0.1',
        port: 5173,
        proxy: {
            '/api': {
                // target: 'http://localhost:9001',	//实际请求地址
                target: 'http://47.99.61.110:9001',	//实际请求地址
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, '')
            },
        }
    },

} );
